<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://xmlns.jcp.org/jsf/core">
    <h:head>
        <title>#{courseBean.predmet.sifra}</title>
        <h:outputStylesheet library="css" name="styles.css"/> 
    </h:head>
    <h:body>
        <ui:include src="menuBar.xhtml"/>
        <h:form enctype="multipart/form-data">
            <p:panel header="#{courseBean.predmet.naziv}" styleClass="headerPanel">
                <p:tabView>
                    <p:tab title="Obavestenja">
                        <div class="infoFrag">
                            <ui:repeat value="#{courseBean.infoList}" var="o">
                                <p:fieldset legend="#{o.naslov}    #{o.datum}">
                                    <h:outputText value="#{o.tekst}"/>
                                </p:fieldset>
                                <br/>
                            </ui:repeat>
                        </div>
                    </p:tab>
                    -
                    <p:tab title="Informacije">
                        <p:panelGrid columns="2">
                            <h:outputLabel value="Sifra:"/>
                            <h:outputLabel value="#{courseBean.predmet.sifra}"/>

                            <h:outputLabel value="Tip:"/>
                            <h:outputLabel value="#{courseBean.predmet.tip}" />

                            <h:outputLabel value="Odsek:"/>
                            <h:outputLabel value="#{courseBean.katedra.opis}"/>

                            <h:outputLabel value="Semestar:"/>
                            <h:outputLabel value="#{courseBean.predmet.semestar}"/>

                            <h:outputLabel value="Fond casova:"/>
                            <h:outputLabel value="#{courseBean.predmet.fondCasova}"/>

                            <h:outputLabel value="Semestar:"/>
                            <h:outputLabel value="#{courseBean.predmet.semestar}"/>

                            <h:outputLabel value="ESPB:"/>
                            <h:outputLabel value="#{courseBean.predmet.espb}"/>

                            <h:outputLabel value="Informacije:"/>
                            <h:outputLabel value="#{courseBean.predmet.informacije}"/>

                            <h:outputLabel value="Semestar:"/>
                            <h:outputLabel value="#{courseBean.predmet.semestar}"/>


                        </p:panelGrid>
                    </p:tab>

                    <p:tab title="Materijali">
                        <p:panelGrid columns="2" styleClass="materijali">
                            <p:panel header="Predavanja">
                                <p:dataTable value="#{courseBean.predavanja}" var="mp">
                                    <p:column headerText="Naziv" sortBy="naziv">
                                        <h:outputLabel value="#{mp.naziv}"/>
                                    </p:column>

                                    <p:column styleClass="downloadBtn">
                                        <p:commandButton icon="ui-icon-arrowthickstop-1-s" actionListener="#{fileBean.getFileById(mp)}" ajax="false" />
                                    </p:column>
                                </p:dataTable>
                            </p:panel>

                            <p:panel header="Vezbe">
                                <p:dataTable value="#{courseBean.vezbe}" var="mv">
                                    <p:column headerText="Naziv" sortBy="naziv">
                                        <h:outputLabel value="#{mv.naziv}"/>
                                    </p:column>

                                    <p:column  style="width: 30px">
                                        <p:commandButton icon="ui-icon-arrowthickstop-1-s" actionListener="#{fileBean.getFileById(mv)}" ajax="false" />
                                    </p:column>
                                </p:dataTable>
                            </p:panel>
                        </p:panelGrid>

                    </p:tab>

                    <p:tab title="Ispitni zadaci">
                        <p:dataTable value="#{courseBean.rokovi}" var="rok" styleClass="materijali">
                            <p:column headerText="Naziv" sortBy="naziv">
                                <h:outputLabel value="#{rok.naziv}"/>
                            </p:column>

                            <p:column styleClass="downloadBtn">
                                <p:commandButton icon="ui-icon-arrowthickstop-1-s" actionListener="#{fileBean.getFileById(rok)}" ajax="false" />
                            </p:column>
                        </p:dataTable>
                    </p:tab>

                    <p:tab title="Laboratorija">
                        <div class="infoFrag">
                            <ui:repeat value="#{courseBean.lab}" var="pd">
                                <p:fieldset legend="#{pd.naziv}" toggleSpeed="500" toggleable="true" collapsed="true">
                                    <br/>
                                    <h:outputLabel value="#{pd.propozicije}"/>
                                    <br/>
                                    <p:dataTable value="#{courseBean.toList(pd.fajlovis)}" var="m">
                                        <p:column headerText="Naziv" sortBy="naziv">
                                            <h:outputLabel value="#{m.naziv}"/>
                                        </p:column>

                                        <p:column styleClass="downloadBtn">
                                            <p:commandButton icon="ui-icon-arrowthickstop-1-s" actionListener="#{fileBean.getFileById(m)}" ajax="false" />
                                        </p:column>
                                    </p:dataTable>
                                </p:fieldset>
                            </ui:repeat>
                        </div>
                    </p:tab>

                    <p:tab title="Projekat / Domaci zadaci">
                        <div class="infoFrag">
                            <ui:repeat value="#{courseBean.domaci}" var="pd">
                                <p:fieldset legend="#{pd.naziv}" toggleSpeed="500" toggleable="true" collapsed="true">
                                    <br/>
                                    <h:outputText value="#{pd.opis}"/>
                                    <br/><br/>
                                    <p:dataTable value="#{courseBean.toList(pd.fajlovis)}" var="m" >
                                        <p:column headerText="Materijali" sortBy="naziv">
                                            <h:outputLabel value="#{m.naziv}"/>
                                        </p:column>
                                        <p:column styleClass="downloadBtn">
                                            <p:commandButton icon="ui-icon-arrowthickstop-1-s" actionListener="#{fileBean.getFileById(m)}" ajax="false" />
                                        </p:column>
                                    </p:dataTable>
                                </p:fieldset>
                                <br/>
                            </ui:repeat>
                        </div>
                    </p:tab>
                    <p:tab title="Spiskovi">
                        <p:dataTable value="#{courseBean.spiskovi}" var="s" >
                            <p:column headerText="Spiskovi" sortBy="naziv">
                                <h:outputLabel value="#{s.naziv}"/>
                            </p:column>
                            <p:column>
                              <p:commandButton value="Prijavi se" actionListener="#{courseBean.setSpisak(s)}" onclick="PF('dlg2').show();" />
                            </p:column>
                        </p:dataTable>
                    </p:tab>
                </p:tabView>
            </p:panel>
            <p:dialog id="modalDialog" header="Prijava" widgetVar="dlg2" modal="true" height="150" width="600" style="font-size: small">
                <p:fileUpload mode="advanced" fileUploadListener="#{courseBean.handleFile}" dragDropSupport="true"/>
               <br/>
                <br/>
                <p:commandButton value="Posalji" action="#{courseBean.prijaviSe()}" onclick="PF('dlg2').hide();"/>
            </p:dialog>
        </h:form>
    </h:body>
</html>

